package com.daxiong.pattern.singleton;

/**
 * 懒汉式单例模式
 *
 * @author sunyanxiong
 * @date 2017/4/23
 */
public class SingletonLazy {

    // 类加载时不进行初始化
    private static SingletonLazy singletonLazy = null;

    private SingletonLazy() {
    }


    // 使用 synchronized 关键字保证多线程下创建单一实例
    public synchronized static SingletonLazy getSingletonLazy() {
        if (null == singletonLazy) {
            singletonLazy = new SingletonLazy();
        }
        return singletonLazy;
    }

}
